<template>
    <div>
        <table>
            <tr>
                <td>id</td>
                <td>名称</td>
                <td>分类</td>
            </tr>
            <tr v-for="i in goodlist">
                <td>{{i.id}}</td>
                <td>{{i.name}}</td>
                <td>
                    <van-button @click='setcate(i.cid)'>{{i.cname}}</van-button>
                </td>
            </tr>
            <tr>
                <van-pagination
                    v-model="page"
                    :total-items="total"
                    :items-per-page="size"
                    @change='getgoodlist'
                    />
            </tr>
        </table>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                goodlist:[],
                total:0,
                size:2,
                page:1,
                cid:0

            }
        },
        methods:{
            getgoodlist(p){
                this.page=p
                this.$axios.get('good/goodM?page='+p+'&size='+this.size+'&cid='+this.cid).then(res=>{
                    this.goodlist = res.data.list
                    this.total = res.data.total
                })
            },
             setcate(cid){
                this.cid=cid
                this.getgoodlist(1)
        }
        },
        mounted(){
            this.getgoodlist(1)
        }
    }
</script>

<style scoped>

</style>